package com.atguigu.ssm.service.impl;

import com.atguigu.ssm.bean.User;
import com.atguigu.ssm.mapper.UserMapper;
import com.atguigu.ssm.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wk
 * @create 2021-06-08 11:13
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> getUserList(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userMapper.selectByExample(null);
        PageInfo<User> pageInfo = new PageInfo<>(list,5);
        return pageInfo;
    }

    @Override
    public void deleteById(int id) {
        userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public User selectById(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(User user) {
        userMapper.updateByPrimaryKey(user);
    }
}
